package com.example.administrator.testproject.download.DownLoadListener;

import com.example.administrator.testproject.downM3U8.ItemM3U8Ts;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * 成功回调处理
 * Created by WZG on 2016/10/20.
 */
public class DownloadM3U8Interceptor implements Interceptor {

    private DownloadProgressListener listener;

    private ItemM3U8Ts info;

    public DownloadM3U8Interceptor(DownloadProgressListener listener, ItemM3U8Ts info) {
        this.listener = listener;
        this.info=info;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response originalResponse = chain.proceed(chain.request());

        return originalResponse.newBuilder()
                .body(new DownloadM3U8ResponseBody(originalResponse.body(), listener,info))
                .build();
    }
}
